<%@page import="com.entity.Project"%>
<%@page import="com.entity.Employee"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>编辑项目</title>
</head>
<body>
	
	<%
		List<Employee> employees=(List<Employee>)request.getAttribute("employees");
		String workers=(String)request.getAttribute("workers");
		Employee admin=(Employee)request.getAttribute("admin");
		Project project=(Project)request.getAttribute("project");
	 %>
	
	<div class="container well" style="width:800px">
		<h1>编辑项目</h1>
		<div>
			<form id="form" action="updateproject.jspx" method="post" class="form-horizontal well">
				
				<label>项目名称</label>
				<input id="input01" style="height:30px" type="text" value="<%=project.getName() %>" class="input-xlarge" name = "projectName">
				 <span style="color:red" id="input01_msg"></span>
				<br /><br>
				
				<label>项目描述</label>
				<textarea rows="3" id="input02" class="span7" name = "projectDesc"><%=project.getDesc() %></textarea>
				 <span style="color:red" id="input02_msg"></span>
				<br /><br>
				
				<label>负责人</label>
				<select name="projectAdmin" id="input03">
					<option value="<%=admin.getId() %>" selected="selected"><%=admin.getUsername() %></option>
					<%
						for(Employee e:employees){
							if(!e.getUsername().equals(admin.getUsername())){
						
					%>
						<option value="<%=e.getId()%>"><%=e.getUsername() %></option>
					<%
							}
						}
					%>
				</select>
				 <span style="color:red" id="input03_msg"></span>
				<br /><br>
				
				<label>项目成员</label>
				<input id="input04" type="text" name="people" value="<%=workers %>" style="height:30px;width:300px" placeholder="多个人名请用','隔开">
				 <span style="color:red" id="input04_msg"></span>
				<br><br>
		
				<input type="submit" class="btn btn-primary" value="保存项目"/>
				<a class="btn" href="projectlist.jspx">取消</a>
				
			</form>
		</div>
	</div>
	
	<script type="text/javascript">
		document.getElementById("form").onsubmit=function(){
			
			var input01 = document.getElementById("input01").value;
			var input02 = document.getElementById("input02").value;
			var input03 = document.getElementById("input03").value;
			var input04 = document.getElementById("input04").value;
			
			if(input01.trim() == "") {
				document.getElementById("input01_msg").innerHTML = "请输入项目名称";
				document.getElementById("input01").focus();
				return false;
			}
				if(input02.trim() == "") {
				
				document.getElementById("input02_msg").innerHTML = "请输入项目描述";
				document.getElementById("input02").focus();
				return false;
			}
				if(input03 == "") {
				
				document.getElementById("input03_msg").innerHTML = "请选择项目负责人";
				document.getElementById("input03").focus();
				return false;
			}
				if(input04.trim() == "") {
				
				document.getElementById("input04_msg").innerHTML = "请输入项目成员";
				document.getElementById("input04").focus();
				return false;
			}
			
		};
		
		document.getElementById("input01").onblur = function(){
		
			var input01 = document.getElementById("input01").value;
			if(input01.trim() == "") {
				document.getElementById("input01").value = "";
				document.getElementById("input01_msg").innerHTML = "请输入项目名称";
				document.getElementById("input01").focus();
			}else{
				document.getElementById("input01_msg").innerHTML = "";
			}
		};
		document.getElementById("input02").onblur = function(){
		
			var input02 = document.getElementById("input02").value;
			if(input02.trim() == "") {
				document.getElementById("input02").value = "";
				document.getElementById("input02_msg").innerHTML = "请输入项目";
				document.getElementById("input02").focus();
			}else{
				document.getElementById("input02_msg").innerHTML = "";
			}
		};
		document.getElementById("input03").onblur = function(){
		
			var input03 = document.getElementById("input03").value;
			if(input03 == "") {
				document.getElementById("input03").value = "";
				document.getElementById("input03_msg").innerHTML = "请选择项目负责人";
				document.getElementById("input03").focus();
			}else{
				document.getElementById("input03_msg").innerHTML = "";
			}
		};
		document.getElementById("input04").onblur = function(){
		
			var input04 = document.getElementById("input04").value;
			if(input04.trim() == "") {
				document.getElementById("input04").value = "";
				document.getElementById("input04_msg").innerHTML = "请输入项目成员";
				document.getElementById("input04").focus();
			}else{
				document.getElementById("input04_msg").innerHTML = "";
			}
		};
		
		document.getElementById("input01").onkeydown = function(){
			document.getElementById("input01_msg").innerHTML = "";
		};
		document.getElementById("input02").onkeydown = function(){
			document.getElementById("input02_msg").innerHTML = "";
		};
		document.getElementById("input03").onchange = function(){
			document.getElementById("input03_msg").innerHTML = "";
		};
		document.getElementById("input04").onkeydown = function(){
			document.getElementById("input04_msg").innerHTML = "";
		};
	
	</script>
</body>
</html>